Crate graph_oauth

source ·
Expand description

§Microsoft Identity Platform Client

Support For OAuth 2.0 and OpenId authorization flows from the Microsoft Identity Platform.

Part of the graph-rs-sdk project on GitHub

§Example ConfidentialClientApplication Authorization Code Flow

use url::Url;
use graph_oauth::{AuthorizationCodeCredential, ConfidentialClientApplication};

pub fn authorization_url(client_id: &str) -> anyhow::Result<Url> {
    Ok(ConfidentialClientApplication::builder(client_id)
        .auth_code_url_builder()
        .with_redirect_uri(Url::parse("http://localhost:8000/redirect")?)
        .with_scope(vec!["user.read"])
        .url()?)
}

pub fn get_confidential_client(authorization_code: &str, client_id: &str, client_secret: &str) -> anyhow::Result<ConfidentialClientApplication<AuthorizationCodeCredential>> {
    Ok(ConfidentialClientApplication::builder(client_id)
        .with_auth_code(authorization_code)
        .with_client_secret(client_secret)
        .with_scope(vec!["user.read"])
        .with_redirect_uri(Url::parse("http://localhost:8000/redirect")?)
        .build())
}
§Supported Authorization Flows From The Microsoft Identity Platform

Modules§

Structs§

Enums§

  • Specifies which Microsoft accounts can be used for sign-in with a given application. See https://aka.ms/msal-net-application-configuration
  • Specifies which Microsoft accounts can be used for sign-in with a given application. See https://aka.ms/msal-net-application-configuration
  • The specification defines errors here: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-31#section-4.2.2.1
  • STS instance (for instance https://login.microsoftonline.com for the Azure public cloud). Maps to the instance url string.
  • Response types used when polling for a device code https://datatracker.ietf.org/doc/html/rfc8628#section-3.5
  • Indicates the type of user interaction that is required. Valid values are login, none, consent, and select_account.
  • Specifies how the identity platform should return the requested token to your app.

Traits§